#include "background.h"

void background::carregar(char* imagePath, char* floorPath)
{
	image = SDL_LoadBMP(imagePath);
	floor = SDL_LoadBMP(floorPath);
	SDL_SetColorKey(floor, SDL_SRCCOLORKEY, SDL_MapRGB(image->format, 255, 0, 255) );
}

void background::desenhar(SDL_Surface *screen, int position)
{
	// Fundo
	imagesrc.w = screen->w;
	imagesrc.h = screen->h;
	imagesrc.x = position;
	imagesrc.y = 0;
	
	SDL_Rect imagedest;
	imagedest.w = screen->w;
	imagedest.h = screen->h;
	imagedest.x = 0;
	imagedest.y = 0;
	
	SDL_BlitSurface(image, &imagesrc, screen, &imagedest);
	
	// Chao
	floorsrc.w = screen->w;
	floorsrc.h = screen->h;
	floorsrc.x = position + (position/2);
	floorsrc.y = 0;
	
	SDL_Rect floordest;
	floordest.w = screen->w;
	floordest.h = screen->h;
	floordest.x = 0;
	floordest.y = screen->h - floor->h;
		
	SDL_BlitSurface(floor, &floorsrc, screen, &floordest);
}

void background::desenharChefe(SDL_Surface *screen)
{
		// Fundo
	imagesrc.w = screen->w;
	imagesrc.h = screen->h;
	imagesrc.x = 0;
	imagesrc.y = 0;
	
	SDL_Rect imagedest;
	imagedest.w = screen->w;
	imagedest.h = screen->h;
	imagedest.x = 0;
	imagedest.y = 0;
	
	SDL_BlitSurface(image, &imagesrc, screen, &imagedest);
	
	// Chao
	floorsrc.w = screen->w;
	floorsrc.h = screen->h;
	floorsrc.x = 0;
	floorsrc.y = 0;
	
	SDL_Rect floordest;
	floordest.w = screen->w;
	floordest.h = screen->h;
	floordest.x = 0;
	floordest.y = screen->h - floor->h;
		
	SDL_BlitSurface(floor, &floorsrc, screen, &floordest);
}
